from datetime import datetime

from django.http import HttpResponse
from django.shortcuts import render

# Create your views here.
def movie_list(request):
    return HttpResponse("电影列表.")
def movie_detail(request,movie_id):
    return HttpResponse(f"您获取的电影id是{movie_id}")
def index(request):
    return render(request,"index.html")


def baidu(request):
    return render(request,"baidu.html")

def info(request):
    # 1.普通变量
    username = 'test'
    # 2. 字典类型
    book = {'name':"水浒传","author":"施耐庵"}

    # 3. 列表
    books = [
        {'name': "水浒传", "author": "施耐庵"},
        {'name': "三国演义", "author": "罗贯中"},
    ]
    # 4. 对象
    class Person:
        def __init__(self,realname):
            self.realname = realname
    return render(request,'info.html',context={'username':username,'book':book,'books':books,"person":Person("testuser")})


def label_view(request):
    age = 18
    books = [
        {'name': "水浒传", "author": "施耐庵"},
        {'name': "三国演义", "author": "罗贯中"},
    ]
    return render(request,"label.html",context={"age":age,"books":books})

def filter_view(request):
    greet = "Hello World, Hello Django"
    context = {
        "greet":greet,
        "birthday":datetime.now(),
        "profile": "",
        "age": 15,
        "html":"<h1>Hello Django World!!!</h1>",
        }
    return render(request,"filter.html",context=context)


def template_form(request):
    return render(request,"xfz_index.html")

def static_view(request):
    return render(request,"static.html")